package nongchang.kuaijiecaifu.com.ncapp_android.ui.popup;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.TextView;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import ezy.lite.util.UI;
import nongchang.kuaijiecaifu.com.ncapp_android.R;

public class SureOrderDialog extends Dialog {
    @BindView(R.id.cb_weixin)
    CheckBox cbWeixin;
    @BindView(R.id.cb_yue)
    CheckBox cbYue;
    @BindView(R.id.cb_zhoujie)
    CheckBox cbZhoujie;
    @BindView(R.id.cb_banyuejie)
    CheckBox cbBanyuejie;
    @BindView(R.id.txt_money)
    TextView txtMoney;
    @BindView(R.id.cb_huodaofukuan)
    CheckBox cb_huodaofukuan;
    public SureOrderDialog(Context context) {
        super(context, R.style.Dialog);
        init();
    }

    public interface OnSubmit {
        void onSubmit();
    }

    private OnSubmit onSubmitListener;

    private void init() {
        Window window = this.getWindow();
        window.requestFeature(Window.FEATURE_NO_TITLE);
        window.getDecorView().setPadding(0, 0, 0, 0);
        setContentView(R.layout.dialog_sure_order);
        ButterKnife.bind(this);

        WindowManager.LayoutParams lp = window.getAttributes();
        lp.width = WindowManager.LayoutParams.MATCH_PARENT;
        lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
        //位置设置到底部
        lp.gravity = Gravity.BOTTOM;
        window.setWindowAnimations(R.style.Dialog_DropDown_PopupAnimation);
        window.setAttributes(lp);

    }

    public SureOrderDialog setData(float money) {
        txtMoney.setText(money+"元");
        return this;
    }

    @OnClick({R.id.btn_sure, R.id.btn_close, R.id.cb_weixin, R.id.cb_yue, R.id.cb_zhoujie, R.id.cb_banyuejie,R.id.cb_huodaofukuan})
    void onClick(View view) {
        switch (view.getId()) {
            case R.id.btn_sure:
                if (cbWeixin.isChecked()) {
                    UI.showToast(getContext(), "微信支付");
                } else if (cbZhoujie.isChecked()) {
                    UI.showToast(getContext(), "周结");
                } else if (cbYue.isChecked()) {
                    UI.showToast(getContext(), "余额支付");
                } else if (cbBanyuejie.isChecked()) {
                    UI.showToast(getContext(), "半月结");
                }else if(cb_huodaofukuan.isChecked()){
                    UI.showToast(getContext(), "货到付款");
                }
                break;
            case R.id.btn_close:
                dismiss();
                break;
            case R.id.cb_weixin:
                cbBanyuejie.setChecked(false);
                cbYue.setChecked(false);
                cbZhoujie.setChecked(false);
                cb_huodaofukuan.setChecked(false);
                break;
            case R.id.cb_yue:
                cbWeixin.setChecked(false);
                cbBanyuejie.setChecked(false);
                cbZhoujie.setChecked(false);
                cb_huodaofukuan.setChecked(false);
                break;
            case R.id.cb_zhoujie:
                cbWeixin.setChecked(false);
                cbBanyuejie.setChecked(false);
                cb_huodaofukuan.setChecked(false);
                cbYue.setChecked(false);
                break;
            case R.id.cb_banyuejie:
                cbWeixin.setChecked(false);
                cbYue.setChecked(false);
                cb_huodaofukuan.setChecked(false);
                cbZhoujie.setChecked(false);
                break;
            case R.id.cb_huodaofukuan:
                cbWeixin.setChecked(false);
                cbBanyuejie.setChecked(false);
                cbYue.setChecked(false);
                cbZhoujie.setChecked(false);
                break;
        }
    }
}